﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR409Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR409Response))]
    public class RR409ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR409Response clazz;
        
        public RR409ResponseSerializer(IRR409Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("KOVKood");
            if (clazz.KOVKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KOVKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KOVKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("DokNimi");
            if (clazz.DokNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokNimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokNimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("DokNumber");
            if (clazz.DokNumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokNumber))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DokNumber");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Perenimi");
            if (clazz.Perenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Perenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>Isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>Isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="KOVKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>KOVKood");
                }
                clazz.KOVKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("KOVKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>KOVKood", Reader.LocalName);
            }
            if (Reader.LocalName=="DokNimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>DokNimi");
                }
                clazz.DokNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("DokNimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>DokNimi", Reader.LocalName);
            }
            if (Reader.LocalName=="DokNumber") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>DokNumber");
                }
                clazz.DokNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("DokNumber")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>DokNumber", Reader.LocalName);
            }
            if (Reader.LocalName=="Eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>Eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Eesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>Eesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Perenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>Perenimi");
                }
                clazz.Perenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Perenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>Perenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR409Response>veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR409Response>veatekst", Reader.LocalName);
            }
        }
    }
}
